package com.shengbangtec.controller;


import com.shengbangtec.service.TBackSalaryClueService;
import com.shengbangtec.util.JsonData;
import com.shengbangtec.vo.ClueInfoEveryDayVO;
import com.shengbangtec.vo.ClueInfoForCityVO;
import com.shengbangtec.vo.ClueInfoForMapVO;
import enums.BizCodeEnum;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LBY
 * @since 2021-07-05
 */
@RestController
@RequestMapping("/tBackSalaryClue")
public class TBackSalaryClueController {

    @Autowired
    private TBackSalaryClueService tBackSalaryClueService;

    /**
     * 接受线索条数/涉及总金额
     * @param type 1:接受线索条数，2：涉及总金额
     * @return
     */
    @RequestMapping("/getNumbersOfClues")
    public JsonData getNumbersOfClues(String type){
        if(StringUtils.isEmpty(type)){
            return JsonData.buildCodeAndMsg(BizCodeEnum.MISSING_PARAM.getCode(),BizCodeEnum.MISSING_PARAM.getMessage());
        }
        List<Map<String, Object>> list = tBackSalaryClueService.getNumbersOfClues(type);
        return JsonData.buildSuccess(list,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     * 建设领域饼状图
     * @param type 1:工程建设领域，2：非工程建设领域
     * @return
     */
    @RequestMapping("/getConstructionField")
    public JsonData getConstructionField(String type){
        if(StringUtils.isEmpty(type)){
            return JsonData.buildCodeAndMsg(BizCodeEnum.MISSING_PARAM.getCode(),BizCodeEnum.MISSING_PARAM.getMessage());
        }
        Map<String, Object> map = tBackSalaryClueService.getConstructionField(type);
        return JsonData.buildSuccess(map,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     * 待接收线索
     * @return
     */
    @RequestMapping("/getStayReceiveClues")
    public JsonData getStayReceiveClues(){
        List<Map<String, Object>> list = tBackSalaryClueService.getStayReceiveClues();
        return JsonData.buildSuccess(list,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     * 石家庄线索详情
     * @return
     */
    @GetMapping("clueInfoForCity")
    public JsonData clueInfoForCity(){
        ClueInfoForCityVO clueInfoForCityVO = tBackSalaryClueService.clueInfoForCity();
        return JsonData.buildSuccess(clueInfoForCityVO,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     * 地图
     * @return
     */
    @GetMapping("clueInfoForMap")
    public JsonData clueInfoForMap(){
        List<ClueInfoForMapVO> clueInfoForMapVO = tBackSalaryClueService.clueInfoForMap();
        return JsonData.buildSuccess(clueInfoForMapVO,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     * 每日线索走势
     * @return
     */
    @GetMapping("clueInfoEveryDay")
    public JsonData clueInfoEveryDay(@RequestParam(name = "areaId") String areaId){
        List<ClueInfoEveryDayVO> clueInfoEveryDayVOList = tBackSalaryClueService.clueInfoEveryDay(areaId);
        return JsonData.buildSuccess(clueInfoEveryDayVOList,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     *  办结线索对比
     * @return
     */
    @GetMapping("handleCountCompare")
    public JsonData handleCountCompare(@RequestParam(name = "areaId") String areaId){
        Map<String,Object> rmap = tBackSalaryClueService.handleCountCompare(areaId);
        return JsonData.buildSuccess(rmap,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     *  已解决人数对比
     * @return
     */
    @GetMapping("handlePeopleCompare")
    public JsonData handlePeopleCompare(@RequestParam(name = "areaId") String areaId){
        Map<String,Object> rmap = tBackSalaryClueService.handlePeopleCompare(areaId);
        return JsonData.buildSuccess(rmap,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }

    /**
     *  已解决总金额对比
     * @return
     */
    @GetMapping("handleAmountCompare")
    public JsonData handleAmountCompare(@RequestParam(name = "areaId") String areaId){
        Map<String,Object> rmap = tBackSalaryClueService.handleAmountCompare(areaId);
        return JsonData.buildSuccess(rmap,BizCodeEnum.OPERATION_SUCCESS.getCode(),BizCodeEnum.OPERATION_SUCCESS.getMessage());
    }
}

